package com.lin.controller;

import com.lin.pojo.PageVo;
import com.lin.pojo.SysMenus;

import com.lin.service.SysMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
@RestController
public class SysMenusRestFulController {
    @Autowired
    SysMenusService sysMenusService;

    @PostMapping("sysmenus.action")
    public Map addSysMenus(SysMenus sysMenus){
        return sysMenusService.addSysMenus(sysMenus);
    }

    @DeleteMapping("sysmenus.action/{id}")
    public Map delPerson(@PathVariable int id){
        return sysMenusService.delSysMenus(id);
    }

    @GetMapping("sysmenus.action/{id}")
    public SysMenus editquerybyid(@PathVariable int id){
        SysMenus sysMenus=sysMenusService.getById(id);
        return sysMenus;
    }

    @GetMapping("querymenus.action")
    public List<SysMenus> querymenusbyedit(){
        List<SysMenus> sysMenus=sysMenusService.list();
        return sysMenus;
    }
    
    @PutMapping("sysmenus.action")
    public Map updatePerson(@RequestBody SysMenus sysMenus){
        return  sysMenusService.updateSysMenus(sysMenus);
    }

    @RequestMapping("lplsysmenus.action")
    public List<SysMenus> queryMenuByfid(int pid){
        List<SysMenus> list=sysMenusService.queryMenuByfid(pid);
        return list;
    }

    @GetMapping("sysmenus.action")
    public PageVo<SysMenus> queryMenubycond(SysMenus sysMenus,
                                              @RequestParam(value = "pageno",defaultValue = "1") Integer pageno,
                                              @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        PageVo<SysMenus> pageVo=sysMenusService.querySysMenusbycond(sysMenus,pageno,pagesize);
        return pageVo;
    }

}
